package com.example.demo.dto;

import com.example.demo.entity.NewTask;
import java.time.LocalDateTime;

public class NewTaskDTO {
    private Long id;                 // 任务表主键ID
    private String bizUniqueId;      // 任务全局唯一ID，用于去重
    private Long dataSourceId;       // 数据源ID，关联 data_source 表
    private String dataSourceName;   // 数据源名称
    private String rawData;          // 从数据源抓取的原始数据，JSON格式
    private Integer isAssigned;      // 是否已分配流程，0=未分配，1=已分配
    private String isAssignedText;   // 是否已分配文本
    private Integer isComplete;      // 是否已完成，0=未完成，1=已完成
    private String isCompleteText;   // 是否已完成文本
    private LocalDateTime createdAt; // 任务创建时间
    private LocalDateTime updatedAt; // 任务更新时间

    // 静态方法：从 Entity 转 DTO
    public static NewTaskDTO fromEntity(NewTask newTask) {
        NewTaskDTO dto = new NewTaskDTO();
        dto.setId(newTask.getId());
        dto.setBizUniqueId(newTask.getBizUniqueId());
        dto.setDataSourceId(newTask.getDataSourceId());
        dto.setRawData(newTask.getRawData());
        dto.setIsAssigned(newTask.getIsAssigned());
        dto.setIsAssignedText(newTask.getIsAssigned() == 1 ? "已分配" : "未分配");
        dto.setIsComplete(newTask.getIsComplete());
        dto.setIsCompleteText(newTask.getIsComplete() == 1 ? "已完成" : "未完成");
        dto.setCreatedAt(newTask.getCreatedAt());
        dto.setUpdatedAt(newTask.getUpdatedAt());
        return dto;
    }
    
    public Long getId() {
        return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    public String getBizUniqueId() {
        return bizUniqueId;
    }
    
    public void setBizUniqueId(String bizUniqueId) {
        this.bizUniqueId = bizUniqueId;
    }
    
    public Long getDataSourceId() {
        return dataSourceId;
    }
    
    public void setDataSourceId(Long dataSourceId) {
        this.dataSourceId = dataSourceId;
    }
    
    public String getDataSourceName() {
        return dataSourceName;
    }
    
    public void setDataSourceName(String dataSourceName) {
        this.dataSourceName = dataSourceName;
    }
    
    public String getRawData() {
        return rawData;
    }
    
    public void setRawData(String rawData) {
        this.rawData = rawData;
    }
    
    public Integer getIsAssigned() {
        return isAssigned;
    }
    
    public void setIsAssigned(Integer isAssigned) {
        this.isAssigned = isAssigned;
    }
    
    public String getIsAssignedText() {
        return isAssignedText;
    }
    
    public void setIsAssignedText(String isAssignedText) {
        this.isAssignedText = isAssignedText;
    }
    
    public Integer getIsComplete() {
        return isComplete;
    }
    
    public void setIsComplete(Integer isComplete) {
        this.isComplete = isComplete;
    }
    
    public String getIsCompleteText() {
        return isCompleteText;
    }
    
    public void setIsCompleteText(String isCompleteText) {
        this.isCompleteText = isCompleteText;
    }
    
    public LocalDateTime getCreatedAt() {
        return createdAt;
    }
    
    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }
    
    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }
    
    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }
}